<template lang="jade">
div
	//- Loader And Lister
	h-loader-full(url='loader',:setdata='false')
		h-data-lister(data='list')
			//- Filter
			m-title(icon='add',name='服务轮播管理')
			//- List
			table.list
				ml-header(data='ID:6,图片,类型,链接,排序,操作:13')
				tr(v-for='(v, i) in list')
					td {{v.id}}
					td: img(:src="'http://image.mod.hesq.com.cn/image/'+ v.img")
					td(v-if='v.type==0') 手机首页轮播图
					td(v-if='v.type==1') 直播
					td(v-if='v.type==2') PC首页轮播图
					td(v-if='v.type==3') PC岗位管理轮播图（一键招人才）
					td: input(type='text',v-model='v.url')
					td: input(type='text',v-model='v.sort')
					td
						a(href='javascript:void(0)',class='update',:data-index='i') 更新
						a(href='javascript:void(0)',class='remove',:data-index='i') 删除
			.command
				button(id='update-all') 全部更新
	h-data-adder(url='swiper/add')
		m-title(icon='add',name='添加轮播图')
		table.single
			mf-row(name='类型选择',msg='选择是轮播图还是直播')
				select(v-model='data.type')
					option(value='',disabled) 请选择
					option(value='0') 手机首页轮播图
					option(value='1') 直播
					option(value='2') PC首页轮播图
					option(value='3') PC岗位管理轮播图（一键招人才）
			mf-row(name='轮播图图片',msg='备注:图片尺寸为 750*300px',v-if='data.type!=1'): mf-upload(uploadid='img',amount='1', project='image', category='xiongan/swiper', rule='swiper', :data='data.img', @upload_data='text')
			mf-row(name='轮播图链接',msg='必填',v-if='data.type!=1'): input(type='text',v-model='data.url')
			mf-row(name='直播名称',v-if='data.type==1')
				select(v-model='data.lid')
					option(value='',disabled) 请选择
					option(v-for='n in live', :value='n.id') {{n.name}} 
			mf-row(name='排序'): input(type='text',v-model='data.sort')
			mf-row(name='')
				button(id='button') 确认提交
</template>

<script>
export default {
	data () {
		return {
			loader:{
				list:'swiper/list',
				live:'live/list/manager'
			},
			url:{
		        update:'edit/swiper',
				remove:'swiper/remove'
			},
			list:[],
			live:[],
			data: {
        		sort:0,
				img:[],
				lid:'',
				type: 0,
				url:''
			}
		}
	},
	methods: {
		loadAfter (res) {
			this.list=res.list
			this.live=res.live
		},
		addAfter (res) {
			console.log(this.data)
			this.$msg.success()
			window.location.reload()
		},
    updataAfter (res) {
			this.$msg.success()
			setTimeout("window.location.reload()",1000)
		},
		text(data){
			console.log(data);
			this.data.img = data
		}
	}
}
</script>
<style>
	img{width:80px;}
	.page{ float:right; }
		.page a{background: #4db3ff; color: #fff; padding:3px 10px; border-radius:4px; cursor:pointer;}
		.page b{margin:0 10px;}
</style>